package com.example.shaojun.fragmentpractice;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

public class AnotherRightFragment extends Fragment {
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.another_right_fragment, container, false);
        //直接调用getActivity可以得到此Fragment关联的活动实例，然后可以用调用活动中的方法来通信。
        MainActivity activity = (MainActivity)getActivity();
        activity.print();
        return view;
    }

    @Override
    public void setArguments(Bundle args) {
        super.setArguments(args);
    }


    public void print(){
        //通过getArguments将信息取出来
        String name = getArguments().getString("name");
        Log.d("AnotherRightFragment", "AnotherRightFragment print, name:"+name);
    }
}
